package com.huang;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;

public class Demo5 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();

        Vector<String> vector = new Vector<>();
        vector.add("abc");

        CopyOnWriteArrayList<String> copy = new CopyOnWriteArrayList<>();
        copy.add("abc");

        for(int i = 0;i < 100;i++){
            new Thread(() ->{
                //往集合中添加元素【add 方法并未 synchronized 修饰】
                list.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(list);
            },String.valueOf(i)).start();
        }
    }
}